Skip to content

feat: move doctor into cli-doctor package, extract config into cli-config, clean-up types - #1480

Merged
grabbou merged 19 commits into
react-native-community:masterfrom
nickx720:1047-move-doctor-separate-package
Jan 26, 2022
Merged

grabbou merged 19 commits into
react-native-community:masterfrom
nickx720:1047-move-doctor-separate-package

Conversation

@nickx720

@nickx720 nickx720 commented Sep 29, 2021 •

Copy link
Copy Markdown
Contributor

Summary:

Implemented changes as per the pr

  1. Created a separate directory under packages.
  2. Labelled it as cli-doctor
  3. Moved the contents from doctor to cli-doctor
  4. Updated import paths
  5. Set up package.json under cli-doctor and modelled it along other cli packages like cli-hermes
  6. Ran yarn-install to ensure success local build

From Mike:

  1. Refactored Ora updates and cleaned-up getLoader
  2. Extracted cli-config into a separate package, reorganised tools inside cli so that it contains cli-only code
  3. Checked all package.json's for extraneous dependencies and made sure everything corresponds to the files used

Test Plan:

  1. Yarn install to ensure the dependencies worked on local.
  2. Made all unit tests pass

@grabbou grabbou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. It's a great thing to do such a cleanup. I did left some notes (not a big deal) that need to be applied before this one is good to be merged. Looking forward to it!

@@ -1,5 +1,5 @@
import androidHomeEnvVariables from '../androidHomeEnvVariable';
import {NoopLoader} from '../../../../tools/loader';
import {NoopLoader} from '@react-native-community/cli/src/tools/loader';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not require files directly from source, but rather expose them via public API. TL;DR always require from @react-native-community/cli.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Makes sense

import * as androidWinHelpers from '../../../../tools/windows/androidWinHelpers';
import * as environmentVariables from '../../../../tools/windows/environmentVariables';
import * as androidWinHelpers from '@react-native-community/cli/src/tools/windows/androidWinHelpers';
import * as environmentVariables from '@react-native-community/cli/src/tools/windows/environmentVariables';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all these functions used outside of a Doctor command? If all these tools, such as androidWinHelpers or downloadAndUnzip are used in Doctor only, then you should move them to doctor tools directory as well (first you may need to create one).

Check the recent commit that moves Metro to a separate package, it's a good example of moving the tooling around as well.

0993f62

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure will do thanks.

Comment thread packages/cli-doctor/package.json Resolved
@grabbou grabbou added the on hold label Oct 4, 2021
@grabbou

grabbou commented Jan 24, 2022

Copy link
Copy Markdown
Member

Thanks for the PR. I will continue the work (apply the changes + few tweaks and rebase) and merge it in order to move forward with this one today.

@grabbou

grabbou commented Jan 24, 2022

Copy link
Copy Markdown
Member

This PR is still work in progress. I will return to it tomorrow. There are a few tools that need to be moved around to clean this up.

Comment thread packages/cli-doctor/src/index.ts Resolved
@grabbou grabbou mentioned this pull request Jan 24, 2022
3 tasks done
@grabbou

grabbou commented Jan 25, 2022

Copy link
Copy Markdown
Member

Created a new package: cli-config for things that are exclusive to config only.
Cleaned up dependencies - there were a lot of dependencies missing in package.json, I made sure everything is covered.
Fixed up dependency on Ora - all packages are using getLoader() from tools package and should refer to the type from that package, rather than relying on Ora directly.

Comment thread packages/cli-doctor/src/index.ts Outdated

export const commands = {info, doctor};

export {default as installPods} from './tools/installPods'; No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, I would like to remove dependency on this file from the CLI package.

@grabbou

grabbou commented Jan 25, 2022

Copy link
Copy Markdown
Member

One issue with Ora is remaining and we can merge this. Ignore type error and this is ready for review.

@grabbou grabbou changed the title Changed doctor to cli-doctor feat: move doctor into cli-doctor package, extract config into cli-config, clean-up types Jan 26, 2022
Comment thread packages/cli-types/src/index.ts Resolved
@grabbou
grabbou merged commit 5530cfc into react-native-community:master Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants